#include <iostream>

using namespace std;

int main()
{
    int n1=0,n2=0,temp=0;
    cin>>n1>>n2;
    while(1)
    {
        temp=n1%n2;
        if(!temp)
        {
            cout<<n2<<endl;
            break;
        }
        n1=n2;
        n2=temp;
    }
    return 0;
}
